package num06;

/**
 * 使用枚举
 */
public class Better560 {
    //nums = [1,1,1], k = 2
    public int subarraySum(int[] nums, int k) {
        int count = 0;
        for (int start = 0; start < nums.length; ++start) {
            int sum = 0;
            for (int end = start; end >= 0; --end) {
                sum += nums[end];
                if (sum == k) {
                    count++;
                }
            }
        }
        return count;

    }

    public static void main(String[] args) {
        Better560 better560 = new Better560();
        int[] ints = new int[]{1,1,1,2};
        better560.subarraySum(ints,2);
  }

}
